package cn.maincode.springdate.JpaService.JpaServiceImpl;

import cn.maincode.springdate.JpaService.JpaUserService;
import cn.maincode.springdate.Pojo.Entity.JpaUser;
import cn.maincode.springdate.Repository.JpaUserRepository;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;


@Service
public class JpaUserServiceImpl implements JpaUserService {
    @Resource
    private JpaUserRepository jpaRep;
    @Override
    public JpaUser insert(JpaUser jpaUser) {
        return jpaRep.save(jpaUser);
    }

    @Override
    public void delete(long id) {
        jpaRep.deleteById(id);
    }

    @Override
    public JpaUser findById(long id) {
        return jpaRep.findById(id).orElse(null);
    }

    @Override
    public List<JpaUser> findAll() {
        return jpaRep.findAll();
    }
}
